<template>
	<view class="content">
		<view class="header">
		</view>
		<view class="main">
			<view class="photo">
        <swiper class="swiper" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1200">
          <swiper-item v-for="(item,index) in activityPic" :key="index">
            <view class="swiper-item uni-bg-red">
              <image :src="item" mode=""></image>
            </view>
          </swiper-item>


        </swiper>

			</view>
			<view class="active">
				<view class="activeTitle">
					<text>{{details.activityTitle}}</text>
				</view>
				<view class="activeTime" v-if="0">
					<view class="object">
						<text class="light">活动对象：</text>
						<text>钱塘大学生</text>
					</view>
					<view class="start">
						<text class="light">活动对象：</text>
						<text>钱塘大学生</text>
					</view>
					<view class="stop">
						<text class="light">活动对象：</text>
						<text>钱塘大学生</text>
					</view>
				</view>
			</view>
			<view class="address">
				<text class="light">活动地址：</text>
				<text>{{details.activityAddress}}</text>
			</view>
      <view class="address activeDetail">
        <text class="light">活动开始时间：</text>
        <text>{{details.createTime}}</text>
      </view>
      <view class="address activeDetail">
        <text class="light">活动结束时间：</text>
        <text>{{details.endTime}}</text>
      </view>
			<view class="activeDetail">
				<view class="detailTitle">
					<text>活动详情</text>
				</view>
				<view class="txt">
<!--					<textarea-->
<!--						placeholder="活动详情介绍活动详情介绍活动详情介绍活动详情介绍活动详情介绍活动详情介绍活动详情介绍活动详情介绍活动详情介绍活动详情介绍活动详"-->
<!--						placeholder-style="{-->
<!--							width: 350px;-->
<!--							line-height: 46rpx;-->
<!--							font-size: 28rpx;-->
<!--							font-family: PingFang SC;-->
<!--							font-weight: 500;-->
<!--							color: #646566;-->
<!--						}"-->
<!--						style="background: #FFFFFF; width: 100%;"-->
<!--					>-->

<!--					</textarea>-->
          <u-parse :html="details.activityDesc"></u-parse>
				</view>
			</view>
			<view class="btn">
				<button type="default"
                @tap="nextPage(`/pages/publishActive/publishActive?activeid=${details.id}&edit=edit`)"
        >重新编辑</button>
			</view>
		</view>
		<Tabbar :current="3"></Tabbar>
	</view>
</template>

<script>
  import {emActivityInfo} from '@/api/myCompan'
  import {getDictItems} from '@/api/dict'
	export default {
		data() {
			return {
        details:{},
        activityPic:[]
			};
		},
    onLoad(opt){
      this.emActivityInfo(opt.id)
    },
    computed:{
    },
		methods: {
      //userIncome 年收入 1
      //userEducation 学历 2
      //userCareer 职业 3
      getDictItemsType(type=1,key='user_income'){
        getDictItems(key).then(res=>{
          const {code,result,success} = res;
          if(success&&code===200){
            const {userIncome,userEducation,userCareer} = this.$store.state.userInfo
            const details = this.details
            result.map(item=>{
              if(type===1){
                if(userIncome===+item.value){
                  details.userIncomeValue = item.title
                }
              }else if(type===2){
                if(userEducation===+item.value){
                  details.userEducationValue = item.title
                }
              }else if(type===3){
                if(userCareer===+item.value){
                  details.userCareerValue = item.title
                }
              }
            })
          }
        }).catch(err=>{
          console.log (err)
        })
      },
      //活动详情
      emActivityInfo(id){
        emActivityInfo(id).then(res=>{
          const {code,result} = res;
          if(code===200){
            this.details = result
            this.getDictItemsType(1)
            this.getDictItemsType(2,'user_education')
            this.getDictItemsType(3,'user_career')
            const ac= this.details
            if(ac){
              const bd=ac&&ac.activityPic.split(',')
              this.activityPic = bd
            }
          }
        }).catch(e=>{
          console.log (e)
        })
      },
			//跳转列表对应页面
			nextPage(url) {
				uni.navigateTo({
					url: url,
					fail() {
						uni.switchTab({
							url: url,
							fail() {
								uni.showToast({
									title: '暂未开通，敬请期待！',
									icon: 'none'
								});
							}
						});
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
.content{
	.header{
		background: linear-gradient(90deg, #52B8B2 0%, #5EC8A3 100%);
		.title{
			position: relative;
			width: 100%;
			height: 120rpx;
			line-height: 120rpx;
			text-align: center;
			.u-icon{
				position: absolute;
				height: 120rpx;
				left: 20rpx;
			}
			text{
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #FFFFFF;
			}
		}
	}
	.main{
		height: 100%;
		background: #F0F3F5;
		.photo{
			image{
				width: 100%;
				height: 320rpx;
			}
		}
		.active{
			position: relative;
			top: -20rpx;
			padding: 20rpx 30rpx;
			background: #FFFFFF;
			border-top-right-radius: 20rpx;
			border-top-left-radius: 20rpx;
			.activeTitle{
				margin-bottom: 10rpx;
				padding-bottom: 10rpx;
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #323233;
				border-bottom: #EFEFEF 2rpx solid;
			}
			.activeTime{
				.light{
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #969799;
				}
				text{
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #323233;
				}
			}
			.object{
				margin-bottom: 10rpx;
			}
			.start{
				margin-bottom: 10rpx;
			}
		}
		.address{
			margin-top: 4rpx;
			padding: 20rpx;
			background: #FFFFFF;
			.light{
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #969799;
			}
			text{
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #323233;
			}
		}
		.activeDetail{
			margin-top: 20rpx;
			padding: 20rpx;
			background: #FFFFFF;
			.detailTitle{
				margin-bottom: 20rpx;
				text{
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #323233;
				}
			}
		}
		.btn{
			position: absolute;
			bottom: 170rpx;
			width: 100%;
			padding: 0 30rpx;
			button{
				height: 78rpx;
				font-size: 32rpx;
				letter-spacing: 2rpx;
				font-family: PingFang SC;
				font-weight: bold;
				background: #57BFAB;
				color: #FFFFFF;
				border-radius: 40rpx;
			}
		}
	}
}
</style>
